package org.compression.controller;

import org.compression.services.BaseService;
import org.model.business.AddModel;
import org.model.business.BookMagament;
import org.model.comm.Page;
import org.model.comm.UpdateModel;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;


@RestController
public abstract class BaseController<T,M> {

	@Autowired
	T mBaseService;
	
	
	//分页查询
	@RequestMapping(value ="/getMember", method = RequestMethod.POST)
	public  Object getMember(@RequestBody  Page mPage) {
		System.out.println(mPage.getPageSize());
		return ((BaseService) mBaseService).getMember(mPage);
	}
	
	
	//模糊查询
	@RequestMapping(value ="/selectName", method = RequestMethod.POST)
	public  Object selectName(@RequestBody M mBookMagament) {
		return ((BaseService) mBaseService).selectName(mBookMagament);
	}
	
	//新增
	@RequestMapping(value ="/add", method = RequestMethod.POST)
	public Object addbook(@RequestBody UpdateModel<M> mAddModel) {
		((BaseService) mBaseService).add(mAddModel);
		 return ((BaseService) mBaseService).getMember(mAddModel.getmPage());
	}
	
	//删除
	@RequestMapping(value ="/deleteByPrimaryKey", method = RequestMethod.DELETE)
	public Object deleteByPrimaryKey(@RequestBody UpdateModel<M> mAddModel) {
		((BaseService) mBaseService).deleteByPrimaryKey(mAddModel);
		 return ((BaseService) mBaseService).getMember(mAddModel.getmPage());
	}
	
	//更新
	@RequestMapping(value ="/updateByPrimaryKeySelective", method = RequestMethod.POST)
	public Object updateByPrimaryKeySelective(@RequestBody UpdateModel<M> mAddModel) {
		((BaseService) mBaseService).updateByPrimaryKeySelective(mAddModel);
		 return ((BaseService) mBaseService).getMember(mAddModel.getmPage());
	}
	
	//UUID 查询
	
	
	
	
	
}
